#!/bin/bash

# 定义常量
AUDIO_PATH="/home/xavier/Music/material/"
PLAYSOFT="/usr/bin/mpg123"

# 播放音频文件的函数
play_audio() {
    local audio_file="$1"
    cd "$AUDIO_PATH" || exit 1 # 如果切换目录失败则退出
    "$PLAYSOFT" "$audio_file"
}

# 显示使用方法的函数
usage() {
    echo "格式：$(basename "$0") [选项]"
    echo "  reveille   起床号"
    echo "  start      开始铃声"
    echo "  stop       休息铃声"
    echo "  lights-out 熄灯号"
    echo "  1         起床号"
    echo "  2         开始铃声"
    echo "  3         休息铃声"
    echo "  4         熄灯号"
}

# 根据传入的参数执行相应的动作
case "$1" in
    reveille|1)
        play_audio "起床号.mp3"
        ;;
    start|2)
        play_audio "上课铃.mp3"
        ;;
    stop|3)
        play_audio "下课铃.mp3"
        ;;
    lights-out|4)
        play_audio "熄灯号.mp3"
        ;;
    *)
        usage
        ;;
esac
